<?php	namespace Home\Controller;

class IndexController extends CommonController
{
	//首页
	public function index()
	{
		
//		if(!isset($_SESSION['username'])){
//			
//			$this->success("请先登录","index.php?c=Login&a=login");
//		}
		
		$this->display();
		
	}

	//头部
	public function top()
	{
		
		$this->display('top.php');
	}
	//左边
	public function left()
	{
		$this->display('left.php');
	}
	//右边
	public function right()
	{
		$this->display('right.php');
	}
	//学生管理
	public function banji()
	{
		$data = M()->query("select * from c_five_seven_two");
		$this->assign("data",$data);
		$this->display("banji.php");
	}
	//添加班级
	public function add()
	{
		//判断是否是post提交
		if(IS_POST){
			$add = 	$_POST['add'];
			p($add);
			$rows = M()->exec("insert into c_five_seven_two (class) values('{$add}')");
			if($rows){
				$this->success("添加成功", "index.php?a=banji");
			}else{
				$this->error("添加失败");
			}
		}
		$this->display("add.php");
	}
	//编辑班级
	public function edit()
	{
		//先获取要编辑班级的序号
		$z = $_GET['z'];
			p($z);
			//在数据库中查找要编辑序号的对应值
		$data = M()->query("select * from c_five_seven_two where uid=$z");
		$this->assign("data",$data);
			p($data);
			//判断是否是post提交
		if(IS_POST){
			//获取编辑提交的数据
			$ed = $_POST['edit'];
//			修改数据库
			$rows = M()->exec("update c_five_seven_two set class='{$ed}' where uid=$z");
			if($rows){
				$this->success("修改成功", "index.php?a=banji");
			}else{
				$this->error("修改失败");
			}
			
		}
		$this->display("edit.php");
	}
	//删除班级
	public function delete()
	{
		//获取删除班级序号
		$z = $_GET['z'];
		$rows = M()->exec("delete from c_five_seven_two where uid=$z");
		if($rows){
			$this->success("删除成功", "index.php?a=banji");
		}else{
			$this->error("删除失败");
		}
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
